/*    */ package com.zimbra.cs.service.mail;
/*    */ 
/*    */ import com.zimbra.common.calendar.ZCalendar.ICalTok;
/*    */ import com.zimbra.common.calendar.ZCalendar.ZCalendarBuilder;
/*    */ import com.zimbra.common.calendar.ZCalendar.ZVCalendar;
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.soap.Element;
/*    */ import com.zimbra.common.soap.SoapFaultException;
/*    */ import com.zimbra.cs.mailbox.Mailbox;
/*    */ import com.zimbra.cs.mailbox.OperationContext;
/*    */ import com.zimbra.cs.mailbox.calendar.Invite;
/*    */ import com.zimbra.soap.ZimbraSoapContext;
/*    */ import java.util.List;
/*    */ import java.util.Map;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class ICalReply
/*    */   extends MailDocumentHandler
/*    */ {
/*    */   public Element handle(Element request, Map<String, Object> context)
/*    */     throws ServiceException, SoapFaultException
/*    */   {
/* 39 */     ZimbraSoapContext zsc = getZimbraSoapContext(context);
/* 40 */     Mailbox mbox = getRequestedMailbox(zsc);
/* 41 */     OperationContext octxt = getOperationContext(zsc, context);
/*    */     
/* 43 */     Element icalElem = request.getElement("ical");
/* 44 */     String icalStr = icalElem.getText();
/* 45 */     String sender = icalElem.getAttribute("at", null);
/* 46 */     ZCalendar.ZVCalendar cal = ZCalendar.ZCalendarBuilder.build(icalStr);
/*    */     
/* 48 */     List<Invite> invites = Invite.createFromCalendar(mbox.getAccount(), null, cal, false);
/*    */     
/* 50 */     for (Invite inv : invites) {
/* 51 */       String method = inv.getMethod();
/* 52 */       if (!ZCalendar.ICalTok.REPLY.toString().equals(method)) {
/* 53 */         throw ServiceException.INVALID_REQUEST("iCalendar method must be REPLY (was " + method + ")", null);
/*    */       }
/*    */     }
/*    */     
/* 57 */     for (Invite inv : invites) {
/* 58 */       mbox.processICalReply(octxt, inv, sender);
/*    */     }
/*    */     
/* 61 */     Element response = getResponseElement(zsc);
/* 62 */     return response;
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/service/mail/ICalReply.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */